Use the Content Query Web Part in SharePoint Server
The Content Query web part is
one of the most useful web parts. It is used to display information in
the current site or in other sites in the current site collection,
based on a query. For example, if you want to show an aggregation of
all the announcements from all the sites, this web part does it. It is
a quite complex web part with a lot of options (some of which must be
configured by a developer), but most of them are easy to set up, as
shown here.
The Content Query web part
is available only in publishing sites and is not available in sites
that are not at least under a root publishing site.
The Content Query web part
can be found under the Content Rollup category in the web part
selection pane. After it is added, this web part displays a link to
open the web part’s tool pane to configure the query it should perform.
To modify the query that
the web part performs and display a different kind of content, click
the link to open the tool pane for the web part (see Figure 5).
In the tool pane, expand the Query section to see the options to specify what content should be displayed and from where (see Figure 6).
You can specify whether the
query will be on all sites in the site collection, on a specific site
and its subsites, or on just a specific list. For the last two options,
use the Browse button to open a dialog that enables you to select the
site or list in question (see Figure 7). Click OK to return to the Content Query web part tool pane.
In the List Type selection
box, you can define what kind of list type the web part should look in
for its content. This includes document libraries, pages libraries,
picture libraries, and all other list templates.
The Content Type section
enables you to select what content types the web part will limit its
query to. If you don’t want to specify a specific content type, you can
leave it at the default All Content Types. Otherwise, you can limit it
to a group of content types (for example, all the document content
types) and to a specific content type). To do that, select the content
type group (for example, document content types) and then either select
All Content Types in the second drop-down or select the specific
content type that you want.
Next, you can set the filters (see Figure 8).
You can specify that the web part will display only list items or
documents that have specific values in specific columns by setting up
to three filters on the web part. To do so, scroll down in the tool
pane to the Filters section, and under Show Items When, you select the
column you want, the kind of filter you want, and the value to filter
on. For example, select Company Is Equal to AdventureWorks or Article
Date Is Equal to Today.
In addition to configuring
the query itself, you can modify how the items will be displayed by
expanding the Presentation section of the pane. You can specify how
many items should be displayed; how they should be sorted, grouped, or
styled; and which columns to display (see Figure 9).